package com.base.library.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.base.library.manager.GlideImageManager;
import com.base.library.widget.ImageViewBase;
import com.jude.rollviewpager.RollPagerView;
import com.jude.rollviewpager.adapter.LoopPagerAdapter;

import java.util.List;

/**
 * Created by xiechengzhi on 2017/4/28.
 */

public class AutoLoopAdapter extends LoopPagerAdapter {

    List<String> data;

    public AutoLoopAdapter(RollPagerView viewPager, List<String> data) {
        super(viewPager);
        this.data = data;
    }

    @Override
    public View getView(ViewGroup container, int position) {
        ImageViewBase view = new ImageViewBase(container.getContext());
        GlideImageManager.getInstance(container.getContext()).displayImagePlaceDefault(data.get(position), view);
        view.setScaleType(ImageView.ScaleType.CENTER_CROP);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        return view;
    }

    @Override
    public int getRealCount() {
        return data.size();
    }

}
